package com.love.cloud.common.mybatis.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author hongdongqu
 */
@Data
@MappedSuperclass
public class SimpleBaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Id
    @Column( nullable = false , columnDefinition = "bigint(20) COMMENT '逻辑id主键'")
    private Long id;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @Column(name="create_time", nullable = false , columnDefinition = "DATETIME(6) COMMENT '创建时间'")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Column(name="update_time", nullable = false , columnDefinition = "DATETIME(6) COMMENT '修改时间'")
    private LocalDateTime updateTime;

    /**
     * 乐观锁字段
     */
    @Version
    @Column(nullable = false , columnDefinition = "INT  COMMENT '版本' default 1")
    private Integer version;

    /**
     * 删除标识符
     */
    @TableLogic
    @TableField(select = false)
    @Column(nullable = false , columnDefinition = "INT  COMMENT '逻辑删除标识(0.未删除,1.已删除)' default 0")
    private Integer delFlag;

}
